package com.kotiln.lgc.lib_base.event

import org.greenrobot.eventbus.EventBus
import java.util.*

/**
 *@fileName EventManager
 *@date2021/1/14  16:12
 *@author EventManager$
 *@describe TODO
 *@desc EventBus管理
 */
object EventManager {

    //注册
    fun register(subscriber:Any){
        EventBus.getDefault().register(subscriber)
    }

    //解绑
    fun onRegister(subscriber:Any){
        EventBus.getDefault().unregister(subscriber)
    }

    //发送事件类
    private fun post(event:MessageEvent){
        EventBus.getDefault().post(event)
    }


//---------------------------------Public fun ------------------------------------------
    //发送事件类型
    fun post(type:Int){
        post(MessageEvent(type))
    }

    //发送类型 携带String数据
    fun post(type:Int,string:String){
        val event=MessageEvent(type)
        event.stringValue=string
        post(event)
    }

    //发送类型 携带int数据
    fun post(type:Int,int:Int){
        val event=MessageEvent(type)
        event.intValue=int
        post(event)
    }

    //发送类型 携带boolean数据
    fun post(type:Int,boolean:Boolean){
        val event=MessageEvent(type)
        event.booleanValue=boolean
        post(event)
    }

}